/*
 * Copyright 2023-2024, Haiku, Inc. All rights reserved.
 * Distributed under the terms of the MIT License.
 */
#ifndef _FDT_H_
#define _FDT_H_

#include <SupportDefs.h>
#include <boot/stage2.h>
#include <boot/uart.h>
#include <boot/interrupt_controller.h>

// 设备树相关函数声明
bool dtb_init();
void dtb_set_kernel_args();

// 解析设备树中的特定节点
bool dtb_parse_uart(int node, uart_info *info);
bool dtb_parse_interrupt_controller(int node, intc_info *info);
bool dtb_parse_memory(int node, addr_range &range);
bool dtb_parse_timer(int node, uint64 &frequency);

// 辅助函数
bool dtb_has_fdt_string(const char *prop, int size, const char *pattern);
bool dtb_get_reg(int node, uint32 addressCells, uint32 sizeCells, size_t idx, addr_range &range);
uint32 dtb_get_interrupt(int node);

// 全局变量
extern void *gDTB;

#endif // _FDT_H_